package com.lovo.sys.service.impl;

import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.JSONObject;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.lovo.commom.util.ConstantUtil;
import com.lovo.sys.bean.ProductListingReviewBean;
import com.lovo.sys.mapper.IProductListingReviewMapper;
import com.lovo.sys.service.IProductListingReviewService;
import com.lovo.sys.service.IProductService;
import com.rabbitmq.client.Channel;
import org.springframework.amqp.rabbit.annotation.RabbitListener;
import org.springframework.amqp.rabbit.core.RabbitTemplate;
import org.springframework.amqp.support.AmqpHeaders;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.messaging.handler.annotation.Header;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import org.springframework.util.StringUtils;

import java.io.IOException;

@Service
@Transactional
public class ProductListingReviewServiceImpl implements IProductListingReviewService {
    @Autowired
    private IProductListingReviewMapper mapper;
    @Autowired
    private RabbitTemplate rabbitTemplate;

    @Autowired
    private IProductService productService;

    @Override
    public void add(ProductListingReviewBean productListingReviewBean) {
        if (productListingReviewBean != null) {
            //更改为审核不通过
            productListingReviewBean.setProductStatus(1);
            mapper.updateById(productListingReviewBean);
            //updateProductStatus修改前端的商品状态为审核不通过
            //报存数据到审核系统
            mapper.insert(productListingReviewBean);
            String msg = JSON.toJSONString(productListingReviewBean);
            //mq到前端接受
            rabbitTemplate.convertAndSend("SSc_Sys_Dev", "rabbit.audit", msg);

        }


    }

}
